package com.zhengsr.wanandroid.mvp.model;

import com.zhengsr.corelib.bean.ArticleCollectBean;
import com.zhengsr.corelib.bean.NaviData;
import com.zhengsr.corelib.bean.BannerBean;
import com.zhengsr.corelib.bean.BaseResponse;
import com.zhengsr.corelib.bean.KnowTreeBean;
import com.zhengsr.corelib.bean.LogUpBean;
import com.zhengsr.corelib.bean.LoginBean;
import com.zhengsr.corelib.net.HttpCreate;
import com.zhengsr.corelib.net.HttpServiceApi;
import com.zhengsr.corelib.utils.SprefUtils;

import java.util.List;

import io.reactivex.Observable;

/**
 * Created by zhengshaorui
 * time: 2018/10/5
 */

public class DataManager {

    private HttpServiceApi mServiceApi;
    private static class Holder{
        static final DataManager SINGLE = new DataManager();
    }
    public static DataManager getInstance(){
        return Holder.SINGLE;
    }
    private DataManager(){
        mServiceApi = HttpCreate.getService();
    }

    public Observable<BaseResponse<List<BannerBean>>> loadBannerData(){
        return mServiceApi.getBannerData();

    }

    public Observable<BaseResponse<ArticleCollectBean>> loadArticleList(int num){
        return mServiceApi.getArticleData(num);

    }

    public Observable<BaseResponse<LoginBean>> loginIn(String username,String password){
        return mServiceApi.loginIn(username,password);
    }

    public Observable<BaseResponse<LogUpBean>> register(String username,String password,String rePassword){
        return mServiceApi.register(username,password,rePassword);
    }

    public Observable<BaseResponse<ArticleCollectBean>> loginOut(){
        return mServiceApi.loginOut();
    }

    public Observable<BaseResponse<ArticleCollectBean>> getCollectList(int num){
        return mServiceApi.getCollectList(num);
    }

    public Observable<BaseResponse<ArticleCollectBean>> addCollectArticle(int id){
        return mServiceApi.addCollectArticle(id);
    }

    public Observable<BaseResponse<BaseResponse>> cancelCollectArticle(int id){
        return mServiceApi.cancleCollectAricle(id);
    }

    public String getLoginName(){
        return (String) SprefUtils.getSprefValue(SprefUtils.LOGIN_USERNAME, SprefUtils.SprefType.STRING);
    }

    public String getLoginPassword(){
        return (String) SprefUtils.getSprefValue(SprefUtils.LOGIN_PASSWORD, SprefUtils.SprefType.STRING);
    }

    public Observable<BaseResponse<List<KnowTreeBean>>> getKnowTree(){
        return mServiceApi.getKnowTree();
    }

    public  Observable<BaseResponse<ArticleCollectBean>> getDetailKnowledge( int page, int cid){
        return  mServiceApi.getDetailKnowledge(page,cid);
    }

    public  Observable<BaseResponse<List<NaviData>>> getNaviData(){
        return mServiceApi.getNaviData();
    }



}
